<template>
    <div>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px">
        <div v-show="showForm == 2">
            <div class="container">
                <h3 style="margin-bottom: 20px">产品信息</h3>
                <el-form-item label="产品类型：">
                    {{ruleForm.materialType}}
                </el-form-item>
                <el-row class="demo-ruleForm">
                    <el-col>
                        <el-form-item label="名称：">
                            {{ruleForm.breedName}}
                        </el-form-item>
                        <el-form-item label="物料代码：">
						    {{ruleForm.materialCode}}
						</el-form-item>
						<el-form-item label="产地：">
						    {{ruleForm.address}}
						</el-form-item>
                    </el-col>
                    <!-- <el-col v-show="breedFormShow">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="存货代码：">
                                    {{ruleForm.inventoryCode}}
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="发药机编码：">
                                    {{ruleForm.dispenserCode}}
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-col> -->
                    <el-col :span="12">
                        <el-form-item label="生产日期：">
                            {{ruleForm.time}}
                        </el-form-item>

                        <!-- <el-form-item label="生产相关人：">
                            {{relevantUserShow}}
                        </el-form-item> -->
                        <el-form-item label="生产工艺：" v-if="ruleForm.materialType != '颗粒包装'">
                            {{ruleForm.technique}}
                        </el-form-item>
                        <el-form-item label="生产批号：">
                            {{ruleForm.batch}}
                        </el-form-item>
                        <!-- <el-form-item label="绑定设备：">
                            <el-select v-model="ruleForm.equipment" filterable placeholder="请选择" style="width: auto">
                                <el-option label="设备一" value="设备一"></el-option>
                                <el-option label="设备二" value="设备二"></el-option>
                            </el-select>
                            <el-button style="margin-left:10px" @click="deviceLink">设备管理</el-button>
                        </el-form-item> -->
                        <el-form-item label="仓库：">
                            {{ruleForm.warehouse}}
                        </el-form-item>
                        <!-- <el-form-item label="生产指令：">
                            <el-input v-model="ruleForm.directive" style="width: auto"></el-input>
                        </el-form-item> -->
                        <el-form-item label="生产场景：" style="width:500px">
                            <span v-for="item in sceneUrls" :key="item.id">
                                <img :src="item.url" width="150" />
                            </span>
                        </el-form-item>
                        <el-form-item label="质量标准：">
                            {{ruleForm.qualityStandard}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">

                        <el-form-item label="生产负责人：">
                            {{ruleForm.principalUser}}
                        </el-form-item>
                        <el-form-item label="生产堆密度：">
                            {{ruleForm. productBulkDensity}}
                        </el-form-item>
                        <el-form-item label="" v-if="ruleForm.materialType != '配方颗粒'">
                            &nbsp;&nbsp;
                        </el-form-item>
                        <el-form-item label="实际产量：">
                            {{ruleForm.totalNumber}}{{ruleForm.units}}
                        </el-form-item>
                        <el-form-item label="">
                            &nbsp;&nbsp;
                        </el-form-item>
                        <el-form-item label="产品图片：" style="width:500px">
                            <span v-for="item in productUrls" :key="item.id">
                                <img :src="item.url" width="150" />
                            </span>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="container" style="margin-top:20px">
                <h3 style="margin-bottom: 20px">原料信息</h3>
                <el-form-item
                    required
                    v-for="(item, index) in ruleForm.list"
                    :label="'原料' + (index+1)"
                    :key="item.key"
                    :prop="'list.' + index + '.breedName'"
                    :rules="{
                        required: true, message: '不能为空', trigger: 'change'
                    }"
                >
                    <el-input :disabled="true" v-model.trim="item.breedName" placeholder="名称" style="width:200px; margin-left: 15px"></el-input>
                    <el-input :disabled="true" v-model.trim="item.inBatch" placeholder="入库批次" style="width:200px; margin-left: 15px"></el-input>
                    <el-input :disabled="true" v-model.trim="item.useNumber" placeholder="投入量" style="width:200px; margin-left: 15px"></el-input>
                    {{item.units}}

                    <el-input :disabled="true" v-model.trim="item.qualityStandard" placeholder="质量标准" style="width:200px; margin-left: 15px"></el-input>
                </el-form-item>
            </div>
            <div class="container" style="margin-top:20px">
                <h3 style="margin-bottom: 20px">辅料信息</h3>
                <el-form-item
                    v-for="(item, index) in ruleForm.flList"
                    :label="'辅料' + (index+1)"
                    :key="item.key"
                >
                    <el-input :disabled="true" v-model.trim="item.breedName" placeholder="名称" style="width:200px; margin-left: 15px"></el-input>
                    <el-input :disabled="true" v-model.trim="item.inBatch" placeholder="入库批次" style="width:200px; margin-left: 15px"></el-input>
                    <el-input :disabled="true" v-model.trim="item.useNumber" placeholder="投入量" style="width:200px; margin-left: 15px"></el-input>
                    {{item.units}}
                </el-form-item>
            </div>
            <el-form-item class="footerFixed">
                <el-button type="primary" @click="submitForm()">确认无误</el-button>
                <el-button @click="backedit">返回修改</el-button>
            </el-form-item>
        </div>
        <div v-show="showForm == 1">
            <div class="container">
                <h3 style="margin-bottom: 20px">产品信息</h3>
                <el-form-item label="产品类型：" prop="materialType">
                    <el-radio-group v-model="ruleForm.materialType" @change="changeMaterType">
                        <el-radio v-if="switchHeadTab == '中药饮片'" label="中药饮片(半成品)" border>中药饮片(半成品)</el-radio>
<!--                        <el-radio v-if="switchHeadTab == '中药饮片'" label="直服饮片" border>直服饮片</el-radio>-->
                        <el-radio v-if='switchHeadTab == "生产系统"' label="提取饮片" border>提取饮片</el-radio>
						<el-radio v-if='switchHeadTab == "生产系统"' label="配方颗粒(浸膏粉)" border>配方颗粒(浸膏粉)</el-radio>
                        <el-radio v-if='switchHeadTab == "生产系统"' label="配方颗粒(颗粒)" border>配方颗粒(颗粒)</el-radio>
                        <!-- <el-radio label="颗粒包装" border>颗粒包装</el-radio> -->
                    </el-radio-group>
                </el-form-item>
                <el-row class="demo-ruleForm">
                    <el-col>
                        <el-form-item label="标准类型：" prop="standard" v-if='switchHeadTab == "生产系统"'>
                            <el-select v-model="ruleForm.standard" @change="gettech"  filterable placeholder="请选择" style="width: 300px;">
                                <el-option label="国标" value="1"></el-option>
                                <el-option label='省标' value="2"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="名称：" prop="breedName">
                            <el-select v-model="ruleForm.breedName"   :remote-method="remoteMethod" @change="changeBreed"  remote value-key="breedName" filterable placeholder="请选择" style="width: auto;">
                                <el-option
                                    v-for="item in breedList"
                                    :key="item.breedName"
                                    :label="item.breedName"
                                    :value="item"
                                >
                                </el-option>
                            </el-select>
                            <el-button style="margin-left:10px" @click="wuliaoLink">物料管理</el-button>
                        </el-form-item>

                        <el-form-item label="物料代码：" prop="materialCode">
                            <el-select v-model="ruleForm.materialCode"   @change='meterialChange'    remote value-key="breedName" filterable placeholder="请选择" style="width: auto;">
                                <el-option
                                    v-for="item in codelist"
                                    :key="item"
                                    :label="item"
                                    :value="item"
                                >
                                </el-option>
                            </el-select>

                        </el-form-item>
						<el-form-item label="产地：">
							<el-input style="width:auto;" disabled v-model.trim="ruleForm.address"></el-input>
						</el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="生产日期：" prop="time">
                            <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" :picker-options="pickerOptions0"  v-model="ruleForm.time" style="width: auto;"></el-date-picker>
                        </el-form-item>

                        <el-form-item label="生产批号：" prop="batch">
                            <el-input v-model.trim="ruleForm.batch" @change="changeBatch" style="width: auto"></el-input>
                        </el-form-item>


                        <el-form-item label="生产工艺：" prop="technique">
                            <el-select v-model="ruleForm.technique" filterable placeholder="请选择" value-key="id" @change="changeTechnique" style="width: auto">
                                <el-option
                                    v-for="item in techniqueList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item"
                                >
                                {{item.name}}
                                </el-option>
                            </el-select>
                            <el-button style="margin-left:10px" @click="craftLink">生产工艺</el-button>
                        </el-form-item>
                        <el-form-item label="实际产量：" prop="totalNumber">
                            <el-input placeholder="请输入" v-model.trim="ruleForm.totalNumber" :disabled="unitDis" style="width: 200px">
                                <template slot="append">
                                    <el-select v-model="ruleForm.units" :disabled="unitDis" placeholder="单位" style="width:80px !important">
                                        <el-option v-for="item in unitList" :key="item.id" :label="item.name" :value="item.name">{{item.name}}</el-option>
                                    </el-select>
                                </template>
                            </el-input>
                            <!-- <el-button style="margin-left:10px" @click="unitLink">单位管理</el-button> -->
                        </el-form-item>
                        <el-form-item label="仓库：" prop="warehouse">
                            <el-select v-model="ruleForm.warehouse" @change="changeWare" filterable value-key="id" placeholder="请选择" style="width: auto;">
                                <el-option
                                    v-for="item in warehouseList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item"
                                >
                                {{item.name}}
                                </el-option>
                            </el-select>
                            <el-button style="margin-left:10px" @click="cangLink">仓库管理</el-button>
                        </el-form-item>
                        <el-form-item label="生产场景：" style="width:500px">
                            <upload-img ref="upload" :files="listUrl" :maxNum="1"></upload-img>
                        </el-form-item>
                        <el-form-item label="质量标准：" style="width:500px">
                            <textarea v-model="ruleForm.qualityStandard" name="" id="" cols="70" rows="6"></textarea>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="生产负责人：" prop="principalUser">
                            <el-select v-model="ruleForm.principalUser" @change="changePrincipa" filterable placeholder="请选择" value-key="id" style="width: auto">
                                <el-option
                                    v-for="item in userList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item"
                                >
                                {{item.name}}
                                </el-option>
                            </el-select>
                            <el-button style="margin-left:10px" @click="staffsLink">员工管理</el-button>
                        </el-form-item>
                        <el-form-item label="生产堆密度：" prop="productBulkDensity">
                            <el-input v-model='ruleForm.productBulkDensity' placeholder="请输入"  style="width: auto"></el-input>
                        </el-form-item>
                        <el-form-item>
							<!-- <el-button @click="getsss">sss</el-button> -->
                            &nbsp;&nbsp;
                        </el-form-item>
                        <el-form-item>
                            &nbsp;&nbsp;
                        </el-form-item>
                        <el-form-item>
                            &nbsp;&nbsp;
                        </el-form-item>
                        <el-form-item label="产品图片：" style="width:500px">
                            <upload-img ref="uploadPin" :files="listUrl1" :maxNum="1"></upload-img>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
            <div class="container" style="margin-top:20px">
                <h3 style="margin-bottom: 20px">原料信息</h3>
                <el-form-item>
                    <div style="width:220px;display:inline-block;">名称</div>
                    <div style="width:220px;display:inline-block;">进厂编号</div>
                    <div style="width:220px;display:inline-block;">投入量</div>
                    <div style="width:220px;display:inline-block;">质量标准</div>
                </el-form-item>
                <el-form-item
                    required
                    v-for="(item, index) in ruleForm.list"
                    :label="'原料' + (index+1)"
                    :key="item.key"
                    :prop="'list.' + index + '.breedName'"
                    :rules="{required: true, message: '不能为空', trigger: 'change'}"
                >
                    <el-select v-model="item.breedName" filterable value-key="id" :remote-method="remoteMethod1" remote @change="changePin(index)" placeholder="名称" style="width:200px">
                        <el-option v-for="item1 in item.breedLists" :key="item1" :label="item1" :value="item1">{{item1}}</el-option>
                    </el-select>
                    <el-select v-model="item.inBatch" filterable value-key="id" :disabled="item.isDisabled" placeholder="进厂编号" @change="changeInBatch(item,index)" style="width:200px;margin: 0 15px">
                        <el-option
                            v-for="item1 in item.inBatchs"
                            :key="item1.id"
                            :label="item1.batch"
                            :value="item1"
                        >
                        {{item1.batch}}
                        </el-option>
                    </el-select>
                    <el-input v-model.number="item.useNumber" type="number" placeholder="投入量" @change="changeNum(index)" style="width:200px"></el-input>
                    <span style="margin-left: 5px">{{item.units}}</span>

                    <el-input v-model="item.qualityStandard" disabled placeholder="质量标准"  style="width:200px"></el-input>
                    <el-button style="margin-left:10px" @click.prevent="removeDomain(item)">删除</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button @click="addDomain">添加一条</el-button>
                </el-form-item>
            </div>
            <div class="container" style="margin-top:20px;padding-bottom:40px;">
                <h3 style="margin-bottom: 20px">辅料信息</h3>
                <el-form-item>
                    <div style="width:220px;display:inline-block;">名称</div>
                    <div style="width:220px;display:inline-block;">进厂编号</div>
                    <div style="width:220px;display:inline-block;">投入量</div>
                </el-form-item>
                <el-form-item
                    v-for="(item, index) in ruleForm.flList"
                    :label="'辅料' + (index+1)"
                    :key="item.key"
                >
                    <el-select v-model="item.breedName" filterable clearable value-key="id" :remote-method="remoteMethod1" remote @change="changePin1(index)" placeholder="名称" style="width:200px">
                        <el-option
                            v-for="item1 in item.breedLists"
                            :key="item1"
                            :label="item1"
                            :value="item1"
                        >
                        {{item1}}
                        </el-option>
                    </el-select>
                    <el-select v-model="item.inBatch" filterable clearable value-key="id" :disabled="item.isDisabled" placeholder="进厂编号" @change="changeInBatch1(item,index)" style="width:200px;margin: 0 15px">
                        <el-option
                            v-for="item1 in item.inBatchs"
                            :key="item1.id"
                            :label="item1.batch"
                            :value="item1"
                        >
                        {{item1.batch}}
                        </el-option>
                    </el-select>
                    <el-input v-model.number="item.useNumber"  type="number" placeholder="投入量" @change="changeNum1(index)" style="width:200px"></el-input>
                    <span style="margin-left: 5px">{{item.units}}</span>
                    <el-button style="margin-left:10px" @click.prevent="removeDomain1(item)">删除</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button @click="addDomain1">添加一条</el-button>
                </el-form-item>
            </div>
            <el-form-item class="footerFixed">
                <el-button type="primary" @click="submitRules('ruleForm')">提交</el-button>
                <el-button @click="backPage">返回</el-button>
            </el-form-item>
        </div>
        </el-form>
    </div>
</template>

<script>
import { getAddressByBatch,sgetAddressByBatch,getcode,pack_findPackBreedName,pack_findMaterialBreedMsg,user_findAll,technology_findByAll,unit_findByList,warehouse_findBreedName,warehouse_findBatchByBreedName,manufacture_save,manufacture_findById,warehouse_findAll,manufacture_update,technology_findByType,manufacture_existBatch,findBreedNameBySearch} from "@/request/api";
import uploadImg from '../../../common/uploadImg';
import { mapState } from 'vuex';
    export default {
        components: {
            uploadImg
        },
        data() {
            return {
				breedName:'',
                showForm: 1,
                breedFormShow: false,
                breedList: [],
                materialType: '',
                userList: [],
                techniqueList: [],
                unitList: [
					{name:"kg"},
					{name:'g'}
				],
                warehouseList: [],
                // relevantUser: [],
                relevantUserName: [],
                relevantUserShow: '',
                qualityStandard:[],
                ruleForm: {
                    productBulkDensity:'',
                    address:'',
                    materialType: '',
                    breedName: '',

                    // relevantUserIds: [],
                    // relevantUsers: '',
                    time: '',
                    // directive: '',
                    // deadLine: '',
                    deadLineUnits: '',
                    techniqueId: '',
                    technique: '',
                    principalUser: '',
                    principalUserId: '',
                    batch: '',
                    equipment: '',
                    equipmentId: '',
                    totalNumber: '',
                    units: 'kg',
                    warehouseId: '',
                    warehouse: '',
                    list: [{
                        manufactureId: '',
                        type: '原料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: '',
                        qualityStandard:''
                    }],
                    flList: [{
                        manufactureId: '',
                        type: '辅料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: ''
                    }],
                    // spec: '',
                    inventoryCode: '',
                    dispenserCode:'',
                    scene: ''
                },
                rules:{
                    // productBulkDensity: [
                    //     { required: true, message: '不能为空', trigger: 'blur' },
                    // ],
                    materialType: [
                        { required: true, message: '不能为空', trigger: 'change' }
                    ],
                    breedName: [
                        { required: true, message: '不能为空', trigger: 'change' },
                    ],
                    time: [
                        { required: true, message: '不能为空', trigger: 'change' }
                    ],
                    totalNumber: [
                        { required: true, message: '不能为空', trigger: 'blur' },
                    ],
                    // deadLine: [
                    //     { required: true, message: '不能为空', trigger: 'blur' },
                    // ],
                    technique:[
                        { required: true, message: '不能为空', trigger: 'change' }
                    ],
                    principalUser: [
                        { required: true, message: '不能为空', trigger: 'change' }
                    ],
                    batch: [
                        { required: true, message: '不能为空', trigger: 'blur' },
                    ],
					standard:[
                        { required: true, message: '不能为空', trigger: 'blur' },
                    ],
					materialCode:[
                        { required: true, message: '不能为空', trigger: 'blur' },
                    ],
					warehouse:[
                        { required: true, message: '不能为空', trigger: 'blur' },
                    ],
                },
				craft:'',
                unitDis: false,
                listUrl: [],
                listUrl1: [],
                materialTypeStor: '',
                sceneUrls: [],
                productUrls: [],
                codelist:[],
                disa:false,

                // 生产日期
                pickerOptions0:{
//                     disabledDate(time){
//                         let _now = Date.now(),
//                         seven = 35 * 30 * 24 * 60 * 60 * 1000,
//                         sevenDays = _now - seven;
//                         return time.getTime() > _now || time.getTime() < sevenDays;
// 　　　　　　　　　　　　　//大于当前的禁止，小于35天前的禁止
//                     }
                },
                // 有效期
                pickerOptions1:{
//                     disabledDate(time){
//                         let _now = Date.now(),
//                         seven = 35 * 30 * 24 * 60 * 60 * 1000,
//                         sevenDays = _now - seven;
//                         return time.getTime() > _now || time.getTime() < sevenDays;
// 　　　　　　　　　　　　　//大于当前的禁止，小于35天前的禁止
//                     }
                },
                items:'',
                // deadLine: ''
            };
        },
        mounted(){
            if(this.$route.query.type == '中药饮片(半成品)' || this.$route.query.type == '直服饮片'){
                this.$store.commit('setSwitchHeadTab','中药饮片')
            }
			this.getuser()
            if(this.$route.query.type == '提取饮片'){
                this.ruleForm.materialType = '提取饮片'
                this.materialType = '提取饮片'
				this.craft = '提取饮片'
            } else if(this.$route.query.type == '配方颗粒(颗粒)'){
                this.ruleForm.materialType = '配方颗粒(颗粒)'
                this.materialType = '配方颗粒(颗粒)'
				this.craft = '配方颗粒(颗粒)'
                this.disa = true
            }else if(this.$route.query.type == '配方颗粒(浸膏粉)'){
                this.ruleForm.materialType = '配方颗粒(浸膏粉)'
                this.materialType = '配方颗粒(浸膏粉)'
				this.craft = '配方颗粒(浸膏粉)'
                this.disa = true
            }else if(this.$route.query.type == '中药饮片(半成品)'){
                this.ruleForm.materialType = '中药饮片(半成品)'
                this.materialType = '中药饮片(半成品)'
                this.craft = '中药饮片(半成品)'
            }else if(this.$route.query.type == '直服饮片'){
                this.ruleForm.materialType = '直服饮片'
                this.materialType = '直服饮片'
                this.craft = '直服饮片'
            }



            console.log(this.materialType)
            // else if(this.$route.query.type == '颗粒包装'){
            //     this.ruleForm.materialType = '颗粒包装'
            //     this.materialType = '颗粒包装'
            // }
            // console.log(this.$route.query)
            var ruleForm = this.$store.state.newStorge
            if (ruleForm != null) {
                if (ruleForm.materialType == '提取饮片'){
                    this.ruleForm = this.$store.state.newStorge
                } else if (ruleForm.materialType == '配方颗粒(颗粒)'){
                    this.ruleForm = this.$store.state.newStorge
                }else if(ruleForm.materialType == '配方颗粒(浸膏粉)'){
					this.ruleForm = this.$store.state.newStorge
				}else if(ruleForm.materialType == '中药饮片(半成品)'){
                    this.ruleForm = this.$store.state.newStorge
                }else if(ruleForm.materialType == '直服饮片'){
                    this.ruleForm = this.$store.state.newStorge
                }
            }
            this.id = this.$route.query.id
            if(this.id == undefined){

                this.init()

                if(this.$route.query.type == '提取饮片'){
                    this.materialTypeStor = '提取饮片'
					this.craft = '提取饮片'
                    this.materialType = '提取饮片'
                } else if(this.$route.query.type == '配方颗粒(颗粒)'){
                    this.materialTypeStor = '配方颗粒(颗粒)'
					this.craft = '配方颗粒(颗粒)'
                    this.materialType = '配方颗粒(颗粒)'
                }
                else if(this.$route.query.type == '配方颗粒(浸膏粉)'){
                    this.materialTypeStor = '配方颗粒(浸膏粉)'
					this.craft = '配方颗粒(浸膏粉)'
                    this.materialType = '配方颗粒(浸膏粉)'
                	this.get()
                }else if(this.$route.query.type == '中药饮片(半成品)'){
                    this.materialTypeStor = '中药饮片(半成品)'
                    this.craft = '中药饮片(半成品)'
                    this.materialType = '中药饮片(半成品)'
                }else if(this.$route.query.type == '直服饮片'){
                    this.materialTypeStor = '直服饮片'
                    this.craft = '直服饮片'
                    this.materialType = '直服饮片'
                }
                this.$store.commit('removeRuform','')
            }else{
                this.init1()
              this.gettech()
            }
            // else if (ruleForm.materialType == '颗粒包装'){
            //     this.ruleForm = this.$store.state.newStorge
            // }
            this.getBreedList()
        },
        computed:{
            ...mapState(['switchHeadTab'])
        },
        methods: {
            getBreedList(){
                pack_findPackBreedName({
                    materialType: this.materialType,
                    ypCodeStandard:this.ruleForm.standard || ''
                }).then((res)=>{
                    this.breedList = res.data
                })
            },
            meterialChange(){
                this.remoteMethod1('')
                warehouse_findBreedName({
                    types: ['原料'],
                    materialTypes: ['辅料'],
                    searchName:''
                }).then((res) =>{
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedLists = res.data
                    }
                    let type = {
                        type:this.craft,
                        breedName:this.ruleForm.breedName
                    }
                    technology_findByType(type).then((res) =>{
                        this.techniqueList = res.data
                    })
                })
            },
			getuser(){
				user_findAll('').then((res)=>{
				    this.userList = res.data
					var list1 = []
					var list2 = []
					for(let k=0;k<this.userList.length;k++){
						if(this.userList[k].name == "何军"){
							list1.push(this.userList[k])
						}else{
							list2.push(this.userList[k])
						}
					}
					this.userList = list1.concat(list2)
				})
			},
            backedit(){
                this.showForm = 1
                //  var arr1 = this.ruleForm.time.split("-")
                // // console.log(arr1)
                // var arr2 = this.ruleForm.deadLine.split("-")
                // var m1 =  Number(arr2[0]) - Number(arr1[0])
                // // console.log(m1)
                // var m2 = Number(arr2[1]) - Number(arr1[1])
                // this.ruleForm.deadLine = m1*12 + m2
                // console.log(this.ruleForm.deadLine)
            },
            backPage () {
                this.$router.go(-1);

                this.$store.commit('setStorName',this.materialTypeStor)
            },
            // 选择物料类型
            changeMaterType(val){
                if(this.materialType == "中药饮片(半成品)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                } else if(this.materialType == "直服饮片"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if (this.materialType == "提取饮片") {
				    warehouse_findBreedName({
				        types: ['原料'],
				        materialTypes: ['中药材'],
				        searchName:'',
				        standard:""
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				} else if(this.materialType == "配方颗粒(颗粒)") {
				    warehouse_findBreedName({
				        types: ['原料','生产'],
				        materialTypes: ['配方颗粒(浸膏粉)'],
				        searchName:'',
				        standard:this.ruleForm.standard
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				}else if(this.materialType == "配方颗粒(浸膏粉)") {
				    warehouse_findBreedName({
				        types: ['原料','生产'],
				        materialTypes: ['提取饮片'],
				        searchName:'',
				        standard:this.ruleForm.standard
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				}

				// 辅料品名
				if (this.materialType == "提取饮片") {
				    warehouse_findBreedName({
				        types: ['原料'],
				        materialTypes: ['辅料'],
				        searchName:''
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.flList.length; i++) {
				            this.ruleForm.flList[i].breedLists = res.data
				        }
				    })
				} else if(this.materialType == "配方颗粒(颗粒)"){
				    warehouse_findBreedName({
				        types: ['原料'],
				        materialTypes: ['辅料'],
				        searchName:''
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.flList.length; i++) {
				            this.ruleForm.flList[i].breedLists = res.data
				        }
				    })
				}else if(this.materialType == "配方颗粒(浸膏粉)"){
				    warehouse_findBreedName({
				        types: ['原料'],
				        materialTypes: ['辅料'],
				        searchName:''
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.flList.length; i++) {
				            this.ruleForm.flList[i].breedLists = res.data
				        }
				    })
				}else if(this.materialType == "中药饮片(半成品)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "直服饮片"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }
                this.ruleForm.breedName = ''
				this.userList = []
                if (val == '提取饮片') {
                    this.disa = false
                    this.materialType = val
					this.craft = val
                    this.ruleForm.technique = ''
                    for (let i = 0; i < this.ruleForm.list.length; i++) {
                        this.ruleForm.list[i].breedName = '';
                        this.ruleForm.list[i].inBatch = ''
                        this.ruleForm.list[i].useNumber = ''
                    }
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedName = '';
                        this.ruleForm.flList[i].inBatch = ''
                        this.ruleForm.flList[i].useNumber = ''
                    }
					user_findAll('').then((res)=>{
					    this.userList = res.data
						var list1 = []
						var list2 = []
						for(let k=0;k<this.userList.length;k++){
							if(this.userList[k].name == "何军"){
								list1.push(this.userList[k])
							}else{
								list2.push(this.userList[k])
							}
						}
						this.userList = list1.concat(list2)
						// console.log(this.userList)
						// this.$set(this.userList,list1.concat(list2))
					})


                    this.init()
                } else if(val == '中药饮片(半成品)'){
                    this.disa = false
                    this.materialType = val
                    this.craft = val
                    this.ruleForm.technique = ''
                    for (let i = 0; i < this.ruleForm.list.length; i++) {
                        this.ruleForm.list[i].breedName = '';
                        this.ruleForm.list[i].inBatch = ''
                        this.ruleForm.list[i].useNumber = ''
                    }
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedName = '';
                        this.ruleForm.flList[i].inBatch = ''
                        this.ruleForm.flList[i].useNumber = ''
                    }
                    user_findAll('').then((res)=>{
                        this.userList = res.data
                        var list1 = []
                        var list2 = []
                        for(let k=0;k<this.userList.length;k++){
                            if(this.userList[k].name == "何军"){
                                list1.push(this.userList[k])
                            }else{
                                list2.push(this.userList[k])
                            }
                        }
                        this.userList = list1.concat(list2)
                    })

                    this.init()
                }else if(val == '直服饮片'){
                    this.disa = false
                    this.materialType = val
                    this.craft = val
                    this.ruleForm.technique = ''
                    for (let i = 0; i < this.ruleForm.list.length; i++) {
                        this.ruleForm.list[i].breedName = '';
                        this.ruleForm.list[i].inBatch = ''
                        this.ruleForm.list[i].useNumber = ''
                    }
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedName = '';
                        this.ruleForm.flList[i].inBatch = ''
                        this.ruleForm.flList[i].useNumber = ''
                    }
                    user_findAll('').then((res)=>{
                        this.userList = res.data
                        var list1 = []
                        var list2 = []
                        for(let k=0;k<this.userList.length;k++){
                            if(this.userList[k].name == "何军"){
                                list1.push(this.userList[k])
                            }else{
                                list2.push(this.userList[k])
                            }
                        }
                        this.userList = list1.concat(list2)
                    })
                    this.init()
                } else if (val == '配方颗粒(颗粒)') {
                    this.disa = true
                    this.materialType = val
					this.craft = "配方颗粒(颗粒)"
                    this.ruleForm.technique = ''
                    for (let i = 0; i < this.ruleForm.list.length; i++) {
                        this.ruleForm.list[i].breedName = '';
                        this.ruleForm.list[i].inBatch = ''
                        this.ruleForm.list[i].useNumber = ''
                    }
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedName = '';
                        this.ruleForm.flList[i].inBatch = ''
                        this.ruleForm.flList[i].useNumber = ''
                    }
					user_findAll('').then((res)=>{
					    this.userList = res.data
						var list1 = []
						var list2 = []
						for(let k=0;k<this.userList.length;k++){
							if(this.userList[k].name == "刘璐"){
								list1.push(this.userList[k])
							}else{
								list2.push(this.userList[k])
							}
						}
						this.userList = list1.concat(list2)
						// console.log(this.userList)
						// this.$set(this.userList,list1.concat(list2))
					})
					// var list1 = []
					// var list2 = []
					// for(let k=0;k<this.userList.length;k++){
					// 	if(this.userList[k].name == "刘璐"){
					// 		list1.push(this.userList[k])
					// 	}else{
					// 		list2.push(this.userList[k])
					// 	}
					// }
					// this.userList = list1.concat(list2)
					// console.log(this.userList)

                    this.init()
                }else if (val == '配方颗粒(浸膏粉)') {
                    this.disa = true
                    this.materialType = val
					this.craft = val
                    this.ruleForm.technique = ''
                    for (let i = 0; i < this.ruleForm.list.length; i++) {
                        this.ruleForm.list[i].breedName = '';
                        this.ruleForm.list[i].inBatch = ''
                        this.ruleForm.list[i].useNumber = ''
                    }
                    for (let i = 0; i < this.ruleForm.flList.length; i++) {
                        this.ruleForm.flList[i].breedName = '';
                        this.ruleForm.flList[i].inBatch = ''
                        this.ruleForm.flList[i].useNumber = ''
                    }
					user_findAll('').then((res)=>{
					    this.userList = res.data
						var list1 = []
						var list2 = []
						for(let k=0;k<this.userList.length;k++){
							if(this.userList[k].name == "陈容"){
								list1.push(this.userList[k])
							}else{
								list2.push(this.userList[k])
							}
						}

						this.userList = list1.concat(list2)


					})

                    this.init()
					this.get()
                }
                // else if (val == '颗粒包装') {
                //     this.materialType = '配方颗粒'
                //     this.init()
                // }
            },
			get(){
				// pack_findPackBreedName({
				//     materialType: "配方颗粒(浸膏粉)",
				//     upperCase:""
				// }).then((res)=>{
				//     this.breedList = res.data
				// })
			},
            getbreedlist(){
                pack_findPackBreedName({
                    materialType: this.materialType,
                    upperCase:"",
                    ypCodeStandard:this.ruleForm.standard
                }).then((res)=>{
                    this.breedList = res.data
                })
            },
            gettech(){
                this.getbreedlist()
				this.ruleForm.breedName = ""
                let type = {
					type:this.craft,
                    standard:this.ruleForm.standard,
                    breedName:this.ruleForm.breedName
				}
                technology_findByType(type).then((res) =>{
                    this.techniqueList = res.data
                })
                if (this.materialType == "提取饮片") {
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:'',
                        standard:""
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "中药饮片(半成品)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:'',
                        standard:""
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "直服饮片"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:'',
                        standard:""
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                } else if(this.materialType == "配方颗粒(颗粒)") {
                    warehouse_findBreedName({
                        types: ['原料','生产'],
                        materialTypes: ['配方颗粒(浸膏粉)'],
                        searchName:'',
                        standard:this.ruleForm.standard
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "配方颗粒(浸膏粉)") {
                    warehouse_findBreedName({
                        types: ['原料','生产'],
                        materialTypes: ['提取饮片'],
                        searchName:'',
                        standard:this.ruleForm.standard
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                }

                // 辅料品名
                if (this.materialType == "提取饮片") {
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "中药饮片(半成品)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "直服饮片"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                } else if(this.materialType == "配方颗粒(颗粒)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "配方颗粒(浸膏粉)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }
            },
            init(){




                // unit_findByList('').then((res) =>{
                //     this.unitList = res.data
                // })
                // 原料品名


                // 仓库
                warehouse_findAll(`?wareHouseType=${this.switchHeadTab=='生产系统'?'1':'2'}`).then((res) =>{
                    this.warehouseList = res.data
                })
            },

			remoteMethod1(query){
				// console.log(query)
				if (this.materialType == "提取饮片") {
				    findBreedNameBySearch({
				        types: ['原料'],
				        materialTypes: ['中药材'],
						searchName:query,
                        standard:""
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				}else if(this.materialType == "中药饮片(半成品)"){
                    findBreedNameBySearch({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:query,
                        standard:""
                    }).then((res) =>{
                        console.log('res:',res);
                        console.log(this.ruleForm);
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "直服饮片"){
                    findBreedNameBySearch({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        searchName:query,
                        standard:""
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            this.ruleForm.list[i].breedLists = res.data
                        }
                    })
                } else if(this.materialType == "配方颗粒(颗粒)") {
				    findBreedNameBySearch({
				        types: ['原料','生产'],
				        materialTypes: ['配方颗粒(浸膏粉)'],
						searchName:query,
                        standard:this.ruleForm.standard
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				}else if(this.materialType == "配方颗粒(浸膏粉)") {
				    findBreedNameBySearch({
				        types: ['原料','生产'],
				        materialTypes: ['提取饮片'],
						searchName:query,
                        standard:this.ruleForm.standard
				    }).then((res) =>{
				        for (let i = 0; i < this.ruleForm.list.length; i++) {
				            this.ruleForm.list[i].breedLists = res.data
				        }
				    })
				}

				//
				// // 辅料品名
				// if (this.materialType == "提取饮片") {
				//     findBreedNameBySearch({
				//         types: ['原料'],
				//         materialTypes: ['辅料'],
				// 		searchName:query
				//     }).then((res) =>{
				//         for (let i = 0; i < this.ruleForm.flList.length; i++) {
				//             this.ruleForm.flList[i].breedLists = res.data
				//         }
				//     })
				// } else if(this.materialType == "配方颗粒(颗粒)"){
				//     findBreedNameBySearch({
				//         types: ['原料'],
				//         materialTypes: ['辅料'],
				// 		searchName:query
				//     }).then((res) =>{
				//         for (let i = 0; i < this.ruleForm.flList.length; i++) {
				//             this.ruleForm.flList[i].breedLists = res.data
				//         }
				//     })
				// }else if(this.materialType == "配方颗粒(浸膏粉)"){
				//     findBreedNameBySearch({
				//         types: ['原料'],
				//         materialTypes: ['辅料'],
				// 		searchName:query
				//     }).then((res) =>{
				//         for (let i = 0; i < this.ruleForm.flList.length; i++) {
				//             this.ruleForm.flList[i].breedLists = res.data
				//         }
				//     })
				// }
			},
            init1(){
                manufacture_findById(this.id).then((res) =>{
                    if (res.data.materialType == '提取饮片') {
                        this.materialType = '提取饮片'
                        this.init()
                    }else if(res.data.materialType == '中药饮片(半成品)'){
                        this.materialType = '中药饮片(半成品)'
                        this.init()
                    }else if(res.data.materialType == '直服饮片'){
                        this.materialType = '直服饮片'
                        this.init()
                    } else if (res.data.materialType == '配方颗粒(颗粒)') {
                        this.materialType = '配方颗粒(颗粒)'
                        this.init()
                    }
                    // else if (res.data.materialType == '颗粒包装') {
                    //     this.materialType = '配方颗粒'
                    //     this.init()
                    // }
                    this.ruleForm = Object.assign({},res.data);
                    if(parseFloat(this.ruleForm.totalNumber) != parseFloat(this.ruleForm.surplusNumber)){
                        this.unitDis = true
                    }
                    if (this.ruleForm.flList.length == 0) {
                        this.ruleForm.flList.push({
                            manufactureId: this.id,
                            type: '辅料',
                            isDisabled: true,
                            breedName: '',
                            inBatch: '',
                            useNumber: '',
                            breedLists: [],
                            inBatchs: [],
                            surplusNum: '',
                            units: ''
                        })
                    }
                    this.materialTypeStor = res.data.materialType

                    if (this.ruleForm.sceneUrl != '') {
                        // 旧图片
                        this.ruleForm.oldSceneUrl = this.ruleForm.sceneUrl
                        // 生产场景
                        var arr = this.ruleForm.sceneUrl.split(",")
                        this.listUrl = arr
                        this.listUrl = arr.map(t =>{
                            var obj = {}
                            obj.url =this.$store.state.imageUrls + t
                            obj.name = this.$store.state.imageUrls + t
                            return obj
                        })
                    }
                    if (this.ruleForm.productUrl != '') {
                        // 旧图片
                        this.ruleForm.oldProductUrl = this.ruleForm.productUrl
                        // 产品图片
                        var arr1 = this.ruleForm.productUrl.split(",")
                        this.listUrl1 = arr1
                        this.listUrl1 = arr1.map(t =>{
                            var obj = {}
                            obj.url =this.$store.state.imageUrls + t
                            obj.name = this.$store.state.imageUrls + t
                            return obj
                        })
                    }
                })
            },
            // 选择相关人
            changeRelevant(ele){
                // console.log(ele)
                // var ids = []
                // var names = []
                // for (let i = 0; i < ele.length; i++) {
                //     ids.push(ele[i].id);
                //     names.push(ele[i].name);
                // }
                // this.ruleForm.relevantUserIds = ids.toString();
                // this.ruleForm.relevantUsers = names.toString();
            },
            // 选择负责人
            changePrincipa(ele){
                this.ruleForm.principalUserId = ele.id
                this.ruleForm.principalUser = ele.name
            },
            // 选择工艺
            changeTechnique(ele){
                this.ruleForm.techniqueId = ele.id
                this.ruleForm.technique = ele.name
            },

			remoteMethod(query){
			   // console.log(query)
			    pack_findPackBreedName({
			        materialType: this.materialType,
			        upperCase:query,
					ypCodeStandard:this.ruleForm.standard
			    }).then((res)=>{
			        this.breedList = res.data

                })

			},
			 // remoteMethod1(query){
				//  findBreedNameBySearch()
			 // },
            // 选择品名
            changeBreed(ele){
				this.ruleForm.breedName = ele.breedName
				this.ruleForm.upperCase = ele.upperCase
                // this.ruleForm.materialCode = ""
                //
                let type = {
                    type:this.craft,
                    standard:this.ruleForm.standard,
                    breedName:this.ruleForm.breedName
                }
                technology_findByType(type).then((res) =>{
                    this.techniqueList = res.data
                })
                console.log(ele.breedName,'$$$');

                getcode(ele.breedName + "&materialType=" +this.materialType + "&ypCodeStandard=" + (this.ruleForm.standard == undefined ? '':this.ruleForm.standard)).then((res)=>{
                    // console.log(res)
                    this.codelist = res.data
                })








                if (this.materialType == "提取饮片") {
                //    console.log(this.ruleForm.list[0].breedLists)
                    let arr = this.ruleForm.list[0].breedLists
                    // if(this.ruleForm.breedName )
                    for(var i=0;i<arr.length;i++){
                        if(this.ruleForm.breedName == arr[i]){
                            this.ruleForm.list[0].breedName = arr[i]
                            this.ruleForm.list[0].isDisabled = false
                            var breedName = this.ruleForm.list[0].breedName
                            if (this.materialType == '提取饮片') {
                                warehouse_findBatchByBreedName({
                                    types: ['原料'],
                                    materialTypes: ['中药材'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }  else if(this.materialType == '配方颗粒(颗粒)'){

                                warehouse_findBatchByBreedName({
                                    types: ['原料','生产'],
                                    materialTypes: ['配方颗粒(浸膏粉)'],
                                    breedName: breedName
                                }).then((res) =>{
                                    // console.log(res)
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }else if(this.materialType == '配方颗粒(浸膏粉)'){
                                // console.log(222)
                                warehouse_findBatchByBreedName({
                                    types: ['原料','生产'],
                                    materialTypes: ['提取饮片'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }
                        }
                    }
                }
                if (this.materialType == "中药饮片(半成品)") {
                    //    console.log(this.ruleForm.list[0].breedLists)
                    let arr = this.ruleForm.list[0].breedLists
                    // if(this.ruleForm.breedName )
                    console.log(arr);
                    for(var i=0;i<arr.length;i++){
                        if(this.ruleForm.breedName == arr[i]){
                            this.ruleForm.list[0].breedName = arr[i]
                            this.ruleForm.list[0].isDisabled = false
                            var breedName = this.ruleForm.list[0].breedName
                            if (this.materialType == '中药饮片(半成品)') {
                                warehouse_findBatchByBreedName({
                                    types: ['原料'],
                                    materialTypes: ['中药材'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }  else if(this.materialType == '直服饮片'){
                                warehouse_findBatchByBreedName({
                                    types: ['原料'],
                                    materialTypes: ['中药材'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }
                        }
                    }
                }
                if (this.materialType == "直服饮片") {
                    //    console.log(this.ruleForm.list[0].breedLists)
                    let arr = this.ruleForm.list[0].breedLists
                    // if(this.ruleForm.breedName )
                    for(var i=0;i<arr.length;i++){
                        if(this.ruleForm.breedName == arr[i]){
                            this.ruleForm.list[0].breedName = arr[i]
                            this.ruleForm.list[0].isDisabled = false
                            var breedName = this.ruleForm.list[0].breedName
                            if (this.materialType == '中药饮片(半成品)') {
                                warehouse_findBatchByBreedName({
                                    types: ['原料'],
                                    materialTypes: ['中药材'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }  else if(this.materialType == '直服饮片'){
                                warehouse_findBatchByBreedName({
                                    types: ['原料'],
                                    materialTypes: ['中药材'],
                                    breedName: breedName
                                }).then((res) =>{
                                    this.ruleForm.list[0].inBatchs = res.data
                                })
                                this.ruleForm.list[0].inBatch = ''
                            }
                        }
                    }
                }
				// pack_findMaterialBreedMsg({
				//     breedName:"",
				//     materialType:this.materialType,
				// }).then((res) =>{
				//     this.breedList = res.data
				// })



            },
            // 生产日期判断

            // 有效期判断

            // 判断生产批号
            changeBatch(val) {
                manufacture_existBatch({batch:val}).then((res) =>{
                    if (res.data == false) {
                        this.$notify.error({
                            title: '提示',
                            message: '批次号重复，请重新输入！',
                            showClose: false,
                            duration:2000
                        });
                        this.ruleForm.batch = "";
                    }
                })
            },
            wuliaoLink(){
                var data = this.$store.getters.permission
                var items = ""
                for (let i = 0; i < data.length; i++) {
                    if(data[i].name == "物料管理"){
                     items = 1
                    }
                }
                if (items == "1"){
                    this.$router.push({
                        path:'/materialsManagement/added'
                    })
                    if (this.ruleForm.materialType=='中药材') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='辅料') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='提取饮片') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='配方颗粒') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if(this.ruleForm.materialType=='中药饮片(半成品)'){
                        this.$store.commit('setStorge',this.ruleForm)
                    }else if(this.ruleForm.materialType=='直服饮片'){
                        this.$store.commit('setStorge',this.ruleForm)
                    }
                }else{
                    this.$router.push({
                        path:'/403'
                    })
                }
            },
            cangLink(){
                var _this = this
                var data = this.$store.getters.permission
                for (let i = 0; i < data.length; i++) {
                    if(data[i].name == "库存管理"){
                        var items = data[i].children
                        setTimeout(function(){
                            for(var k=0;k<items.length;k++){
                                if(items[k].name=="仓库管理"){
                                    this.items = 1
                                }
                            }
                        })
                    }
                }
                setTimeout(function(){
                    if(this.items == "1"){
                        _this.$router.push({
                            path:'/inventory/addInventory'
                        })
                        if (_this.ruleForm.materialType=='中药材') {
                            _this.$store.commit('setStorge',_this.ruleForm)
                        } else if (_this.ruleForm.materialType=='辅料') {
                            _this.$store.commit('setStorge',_this.ruleForm)
                        } else if (_this.ruleForm.materialType=='提取饮片') {
                            _this.$store.commit('setStorge',_this.ruleForm)
                        } else if (_this.ruleForm.materialType=='配方颗粒') {
                            _this.$store.commit('setStorge',_this.ruleForm)
                        }else if(_this.ruleForm.materialType=='中药饮片(半成品)'){
                            _this.$store.commit('setStorge',_this.ruleForm)
                        }else if(_this.ruleForm.materialType=='直服饮片'){
                            _this.$store.commit('setStorge',_this.ruleForm)
                        }
                    }else{
                        _this.$router.push({
                            path:'/403'
                        })
                    }
                },500)
            },
            deviceLink(){
                this.$router.push({
                    path:'/staffIndex'
                })
                if (this.ruleForm.materialType=='中药材') {
                    this.$store.commit('setStorge',this.ruleForm)
                } else if (this.ruleForm.materialType=='辅料') {
                    this.$store.commit('setStorge',this.ruleForm)
                } else if (this.ruleForm.materialType=='提取饮片') {
                    this.$store.commit('setStorge',this.ruleForm)
                } else if (this.ruleForm.materialType=='配方颗粒') {
                    this.$store.commit('setStorge',this.ruleForm)
                }
            },
            craftLink(){
                var data = this.$store.getters.permission
                var items = ""
                for (let i = 0; i < data.length; i++) {
                    if(data[i].name == "工艺工序"){
                     items = 1
                    }
                }
                if (items == "1"){
                    this.$router.push({
                        path:'/process/added'
                    })
                    if (this.ruleForm.materialType=='中药材') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='辅料') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='提取饮片') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='配方颗粒') {
                        this.$store.commit('setStorge',this.ruleForm)
                    }else if(this.ruleForm.materialType=='中药饮片(半成品)'){
                        this.$store.commit('setStorge',this.ruleForm)
                    }else if(this.ruleForm.materialType=='直服饮片'){
                        this.$store.commit('setStorge',this.ruleForm)
                    }
                }else{
                    this.$router.push({
                        path:'/403'
                    })
                }

            },
            staffsLink(){
                var data = this.$store.getters.permission
                var items = ""
                for (let i = 0; i < data.length; i++) {
                    if(data[i].name == "员工管理"){
                        items = 1
                    }
                }
                if (items == "1"){
                    this.$router.push({
                        path:'/staffsManagement/addedstaff'
                    })
                    if (this.ruleForm.materialType=='中药材') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='辅料') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='提取饮片') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='配方颗粒') {
                        this.$store.commit('setStorge',this.ruleForm)
                    }else if (this.ruleForm.materialType=='中药饮片(半成品)') {
                        this.$store.commit('setStorge',this.ruleForm)
                    }else if (this.ruleForm.materialType=='直服饮片') {
                        this.$store.commit('setStorge',this.ruleForm)
                    }
                }else{
                    this.$router.push({
                        path:'/403'
                    })
                }
            },
            unitLink(){
                var data = this.$store.getters.permission
                var items = ""
                for (let i = 0; i < data.length; i++) {
                    if(data[i].name == "单位管理"){
                     items = 1
                    }
                }
                if (items == "1"){
                    this.$router.push({
                        path:'/unit',
                        query:{type:"added"}
                    })
                    if (this.ruleForm.materialType=='中药材') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='辅料') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='提取饮片') {
                        this.$store.commit('setStorge',this.ruleForm)
                    } else if (this.ruleForm.materialType=='配方颗粒') {
                        this.$store.commit('setStorge',this.ruleForm)
                    }
                }else{
                    this.$router.push({
                        path:'/403'
                    })
                }
            },
            changeWare(ele){
                this.ruleForm.warehouseId = ele.id
                this.ruleForm.warehouse = ele.name
            },
            addDomain() {
                if(this.id == undefined){
                    this.ruleForm.list.push({
                        manufactureId: '',
                        type: '原料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: '',
                        key: Date.now()
                    });
                }else{
                    this.ruleForm.list.push({
                        manufactureId: this.id,
                        type: '原料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: '',
                        key: Date.now()
                    });
                }
                this.gettech()
            },
            addDomain1() {
                if(this.id == undefined){
                    this.ruleForm.flList.push({
                        manufactureId: '',
                        type: '辅料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: '',
                        key: Date.now()
                    });
                }else{
                    this.ruleForm.flList.push({
                        manufactureId: this.id,
                        type: '辅料',
                        isDisabled: true,
                        breedName: '',
                        inBatch: '',
                        useNumber: '',
                        breedLists: [],
                        inBatchs: [],
                        surplusNum: '',
                        units: '',
                        key: Date.now()
                    });
                }
                // 辅料品名
                if (this.materialType == "提取饮片") {
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "中药饮片(半成品)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "直服饮片"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                } else if(this.materialType == "配方颗粒(颗粒)"){

                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }else if(this.materialType == "配方颗粒(浸膏粉)"){
                    warehouse_findBreedName({
                        types: ['原料'],
                        materialTypes: ['辅料'],
                        searchName:''
                    }).then((res) =>{
                        for (let i = 0; i < this.ruleForm.flList.length; i++) {
                            this.ruleForm.flList[i].breedLists = res.data
                        }
                    })
                }
                this.init()
            },
            removeDomain(item) {
                if (this.ruleForm.list.length > 1) {
                    this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        var index = this.ruleForm.list.indexOf(item)
                        if (index !== -1) {
                            this.ruleForm.list.splice(index, 1)
                        }
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    });
                }
            },
            removeDomain1(item) {
                if (this.ruleForm.flList.length > 1) {
                    this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        var index = this.ruleForm.flList.indexOf(item)
                        if (index !== -1) {
                            this.ruleForm.flList.splice(index, 1)
                        }
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    });
                }
            },
            changeNum(index){
                if (this.ruleForm.list[index].useNumber <= 0) {
                    this.$notify.error({
                        title: '提示',
                        message: '数量不能为零或负数！',
                        showClose: false,
                        duration:2000
                    });
                    this.ruleForm.list[index].useNumber = this.ruleForm.list[index].surplusNum
                }
                if (this.ruleForm.list[index].useNumber > this.ruleForm.list[index].surplusNum) {
                    this.$notify.error({
                        title: '提示',
                        message: '数量不能大于剩余量！',
                        showClose: false,
                        duration:2000
                    });
                    this.ruleForm.list[index].useNumber = this.ruleForm.list[index].surplusNum
                }
            },
            changeNum1(index){
                if (this.ruleForm.flList[index].useNumber <= 0) {
                    this.$notify.error({
                        title: '提示',
                        message: '数量不能为零或负数！',
                        showClose: false,
                        duration:2000
                    });
                    this.ruleForm.flList[index].useNumber = this.ruleForm.flList[index].surplusNum
                }
                if (this.ruleForm.flList[index].useNumber > this.ruleForm.flList[index].surplusNum) {
                    this.$notify.error({
                        title: '提示',
                        message: '数量不能大于剩余量！',
                        showClose: false,
                        duration:2000
                    });
                    this.ruleForm.flList[index].useNumber = this.ruleForm.flList[index].surplusNum
                }
            },
            changePin(index) {
                this.ruleForm.list[index].isDisabled = false
                const breedName = this.ruleForm.list[index].breedName
                if (this.materialType == '提取饮片') {
                    warehouse_findBatchByBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        breedName: breedName,
                        standard:""
                    }).then((res) =>{
                        this.ruleForm.list[index].inBatchs = res.data
                    })
                    this.ruleForm.list[index].inBatch = ''
                }  else if(this.materialType == '配方颗粒(颗粒)'){

                    warehouse_findBatchByBreedName({
                        types: ['原料','生产'],
                        materialTypes: ['配方颗粒(浸膏粉)'],
                        breedName: breedName,
                        standard:this.ruleForm.standard
                    }).then((res) =>{
                        this.ruleForm.list[index].inBatchs = res.data
                    })
                    this.ruleForm.list[index].inBatch = ''
                }else if(this.materialType == '配方颗粒(浸膏粉)'){
					console.log(222)
                    warehouse_findBatchByBreedName({
                        types: ['原料','生产'],
                        materialTypes: ['提取饮片'],
                        breedName: breedName,
                        standard:this.ruleForm.standard
                    }).then((res) =>{
                        this.ruleForm.list[index].inBatchs = res.data
                    })
                    this.ruleForm.list[index].inBatch = ''
                }else if(this.materialType == '中药饮片(半成品)'){
                    warehouse_findBatchByBreedName({
                        types: ['原料'],
                        materialTypes: ['中药材'],
                        breedName: breedName
                    }).then((res) =>{
                        console.log(res,'$$');
                        console.log(index);
                        this.ruleForm.list[index].inBatchs = res.data
                        // this.ruleForm.list[index].inBatch = this.ruleForm.list[index].inBatchs[0].batch
                        console.log( this.ruleForm,'%%%%');
                    })
                    this.ruleForm.flList[index].inBatch = ''
                }
				this.init()
            },
            changeInBatch(val,index){
                const inBatchs = this.ruleForm.list[index].inBatch
                console.log(inBatchs);
                this.ruleForm.list[index].surplusNum = inBatchs.surplusNum
                this.ruleForm.list[index].useNumber = inBatchs.surplusNum
                this.ruleForm.list[index].relevanceId = inBatchs.id
                this.ruleForm.list[index].inBatch = inBatchs.batch
                this.ruleForm.list[index].units = inBatchs.units
                this.ruleForm.list[index].qualityStandard = inBatchs.qualityStandard
                this.ruleForm.qualityStandard = this.ruleForm.list[index].qualityStandard
                this.getbreedlist()
                if(index == 0){
                    if(this.ruleForm.materialType == "提取饮片" || this.ruleForm.materialType == "中药饮片(半成品)"){
                         getAddressByBatch(inBatchs.batch).then((res)=>{
                            this.ruleForm.address = res.data.address
                        })
                    }else{
                        sgetAddressByBatch(inBatchs.batch).then((res)=>{
                            this.ruleForm.address = res.data.address
                        })
                    }
                }
            },
            changePin1(index) {
                this.ruleForm.flList[index].isDisabled = false
                const breedName = this.ruleForm.flList[index].breedName
				if(breedName == ""){

				}else{
					if (this.materialType == '提取饮片') {
						warehouse_findBatchByBreedName({
							types: ['原料'],
							materialTypes: ['辅料'],
							breedName: breedName
						}).then((res) =>{
							this.ruleForm.flList[index].inBatchs = res.data
						})
						this.ruleForm.flList[index].inBatch = ''
					}else if(this.materialType == '中药饮片(半成品)'){
                        warehouse_findBatchByBreedName({
                            types: ['原料'],
                            materialTypes: ['辅料'],
                            breedName: breedName
                        }).then((res) =>{
                            this.ruleForm.flList[index].inBatchs = res.data
                        })
                        this.ruleForm.flList[index].inBatch = ''
                    }else if(this.materialType == '直服饮片'){
                        warehouse_findBatchByBreedName({
                            types: ['原料'],
                            materialTypes: ['辅料'],
                            breedName: breedName
                        }).then((res) =>{
                            this.ruleForm.flList[index].inBatchs = res.data
                        })
                        this.ruleForm.flList[index].inBatch = ''
                    } else if(this.materialType == '配方颗粒(颗粒)'){
						warehouse_findBatchByBreedName({
							types: ['原料'],
							materialTypes: ['辅料'],
							breedName: breedName
						}).then((res) =>{
							this.ruleForm.flList[index].inBatchs = res.data
						})
						this.ruleForm.flList[index].inBatch = ''
					}else if(this.materialType == '配方颗粒(浸膏粉)'){
						warehouse_findBatchByBreedName({
							types: ['原料'],
							materialTypes: ['辅料'],
							breedName: breedName
						}).then((res) =>{
							this.ruleForm.flList[index].inBatchs = res.data
						})
						this.ruleForm.flList[index].inBatch = ''
					}
				}
				this.init()

            },
            changeInBatch1(val,index){
                const inBatchs = this.ruleForm.flList[index].inBatch
                this.ruleForm.flList[index].surplusNum = inBatchs.surplusNum
                this.ruleForm.flList[index].useNumber = inBatchs.surplusNum
                this.ruleForm.flList[index].relevanceId = inBatchs.id
                this.ruleForm.flList[index].inBatch = inBatchs.batch
                this.ruleForm.flList[index].units = inBatchs.units
            },
            submitRules(formName){
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        var breedName = '';
                        var inBatch = '';
                        var useNumber = '';
                        var breedName1 = '';
                        var inBatch1 = '';
                        var useNumber1 = '';
                        for (let i = 0; i < this.ruleForm.list.length; i++) {
                            breedName = this.ruleForm.list[i].breedName;
                            inBatch = this.ruleForm.list[i].inBatch;
                            useNumber = this.ruleForm.list[i].useNumber;
                        }
                        if (this.ruleForm.flList[0].breedName != '') {
                            for (let i = 0; i < this.ruleForm.flList.length; i++) {
                                breedName1 = this.ruleForm.flList[i].breedName;
                                inBatch1 = this.ruleForm.flList[i].inBatch;
                                useNumber1 = this.ruleForm.flList[i].useNumber;
                            }
                        }
                        // 生产场景
                        this.sceneUrls = this.$refs.upload.fileList
                        // 产品图片
                        // console.log(this.ruleForm.time)
                        this.productUrls = this.$refs.uploadPin.fileList
                        var arr = this.ruleForm.time.split("-")


                        for (let i=0;i<this.ruleForm.list.length;i++){
                            var num = i +1
                            if(this.ruleForm.list[i].breedName == ""){
                                this.$notify({
                                    title: '提示',
                                    message: '原料第' + num + '条名称不能为空',
                                    type: 'info',
                                    duration:1000
                                });
                                return false
                            }
                            if(this.ruleForm.list[i].inBatch == ""){
                                this.$notify({
                                    title: '提示',
                                    message: '原料第' + num + '条批次不能为空',
                                    type: 'info',
                                    duration:1000
                                });
                                return false
                            }
                            if(this.ruleForm.list[i].useNumber == ""){
                                this.$notify({
                                    title: '提示',
                                    message: '原料第' + num + '条投入量不能为空',
                                    type: 'info',
                                    duration:1000
                                });
                                return false
                            }
                        }
                        if(this.ruleForm.flList.length>1){
                            for (let q=0;q<this.ruleForm.flList.length;q++){
                                var num1 = q +1
                                if(this.ruleForm.flList[q].breedName == ""){
                                    this.$notify({
                                        title: '提示',
                                        message: '辅料第' + num1 + '条名称不能为空',
                                        type: 'info',
                                        duration:1000
                                    });
                                    return false
                                }
                                if(this.ruleForm.flList[q].inBatch == ""){
                                    this.$notify({
                                        title: '提示',
                                        message: '辅料第' + num1 + '条批次不能为空',
                                        type: 'info',
                                        duration:1000
                                    });
                                    return false
                                }
                                if(this.ruleForm.flList[q].useNumber == ""){
                                    this.$notify({
                                        title: '提示',
                                        message: '辅料第' +num1 + '条投入量不能为空',
                                        type: 'info',
                                        duration:1000
                                    });
                                    return false
                                }
                            }
                        }

                        // console.log(arr)
                        // var mydate = new Date(Number(arr[0]),Number(arr[1]) + Number(this.ruleForm.deadLine))
                        // console.log(mydate)
                        // var endy = mydate.getFullYear()
                        // var endm = mydate.getMonth()
                        // this.ruleForm.deadLine = endy + "-" + endm

                        // var ids = []
                        // var names = []
                        // for (let i = 0; i < this.relevantUser.length; i++) {
                        //     ids.push(this.relevantUser[i].id);
                        //     names.push(this.relevantUser[i].name);
                        // }
                        // this.ruleForm.relevantUserIds = ids.toString();
                        // this.ruleForm.relevantUsers = names.toString();
                        // this.relevantUserShow = this.ruleForm.relevantUsers

                        // if (this.ruleForm.deadLine != '') {
                        //     if(this.ruleForm.deadLineUnits == ''){
                        //         this.$notify.error({
                        //             title: '提示',
                        //             message: '保质期单位必填！',
                        //             showClose: false,
                        //             duration:2000
                        //         });
                        //     }
                        // } else
                        // if(this.ruleForm.units != ''){
                        //     if(breedName != ''){
                        //         if (inBatch == '') {
                        //             this.$notify.error({
                        //                 title: '提示',
                        //                 message: '原料入库批次必填！',
                        //                 showClose: false,
                        //                 duration:2000
                        //             });
                        //         } else if(inBatch != ''){
                        //             if(useNumber == ''){
                        //                 this.$notify.error({
                        //                     title: '提示',
                        //                     message: '原料投入量必填！',
                        //                     showClose: false,
                        //                     duration:2000
                        //                 });
                        //             } else if(useNumber <= 0){
                        //                 this.$notify.error({
                        //                     title: '提示',
                        //                     message: '原料投入量不能为零或负数！',
                        //                     showClose: false,
                        //                     duration:2000
                        //                 });
                        //             }
                        //         }
                        //     }
                        // }
                        if(breedName1 != ''){
                            if (inBatch1 == '') {
                                this.showForm = 1
                                this.$notify.error({
                                    title: '提示',
                                    message: '辅料入库批次必填！',
                                    showClose: false,
                                    duration:2000
                                });
                            } else if(inBatch1 != ''){
                                this.showForm = 1
                                if(useNumber1 == ''){
                                    this.$notify.error({
                                        title: '提示',
                                        message: '辅料投入量必填！',
                                        showClose: false,
                                        duration:2000
                                    });
                                } else if(useNumber1 <= 0){
                                    this.$notify.error({
                                        title: '提示',
                                        message: '辅料投入量不能为零或负数！',
                                        showClose: false,
                                        duration:2000
                                    });
                                }
                            } else{
                                this.showForm = 2
                            }
                        }
                        if(this.ruleForm.units == ''){
                            this.$notify.error({
                                title: '提示',
                                message: '产量单位必填！',
                                showClose: false,
                                duration:2000
                            });
                        } else{
                            this.showForm = 2
                        }
                    } else {
                        return false;
                    }
                    // console.log(this.ruleForm,222)
                })
            },
            submitForm() {

                const lists = JSON.stringify(this.ruleForm.list)
                this.ruleForm.ylString = lists.toString();
                if (this.ruleForm.flList[0].breedName != '') {
                    const flLists = JSON.stringify(this.ruleForm.flList)
                    this.ruleForm.flString = flLists.toString();
                } else{
                    this.ruleForm.flString = [];
                }

                if (this.ruleForm.flList[0].breedName == '') {
                    this.ruleForm.flList = []
                }
                var formdata = new FormData()
                // 生产场景
                var imgurls = this.$refs.upload.fileList
                var arr=""
                for(var i=0;i<imgurls.length;i++){
                    if(imgurls[i].status != "success"){
                        formdata.append("files",imgurls[i].raw)
                    }
                    arr += imgurls[i].name + ','
                }
                const sceneUrl = arr.substr(0,arr.length-1)
                this.ruleForm.sceneUrl = sceneUrl.substring(sceneUrl.lastIndexOf("/")+1)
                // 产品图片
                var imgurls1 = this.$refs.uploadPin.fileList
                var arr1=""
                for(var i=0;i<imgurls1.length;i++){
                    if(imgurls1[i].status != "success"){
                        formdata.append("files",imgurls1[i].raw)
                    }
                    arr1 += imgurls1[i].name + ','
                }
                const productUrl = arr1.substr(0,arr1.length-1)
                this.ruleForm.productUrl = productUrl.substring(productUrl.lastIndexOf("/")+1)
                // push到formdata
                for(var a in this.ruleForm){
                    formdata.append(a,this.ruleForm[a])
                }
                // console.log(this.ruleForm,11111)

                if(this.id == undefined){
                    manufacture_save(formdata).then((res) => {
                        this.$notify({
                            title: '提示',
                            message: '保存成功',
                            type: 'success',
                            duration:1000
                        });
                        this.backPage()
                    })
                } else{
                    // console.log(this.ruleForm,2222)
                    manufacture_update(formdata).then((res) => {
                        this.$notify({
                            title: '提示',
                            message: '修改成功',
                            type: 'success',
                            duration:1000
                        });
                        this.backPage()
                    })
                }
            },
        }
    }
</script>
<style scoped lang="less">
.el-date-editor.el-input{
    width: 200px !important
}
.el-select{
    width: 200px !important
}
.demo-ruleForm{
    margin-top: 20px;
}
</style>
